// Vue.directive('sy-img', function (e,obj) {
// 	var w = $(e).attr("w");
// 	var h = $(e).attr("h");
// 	var init = $(e).attr("init-src");
// 	e.src = sy.getSrc(obj.value,w,h,init);
// });

Vue.directive('sy-img', {
	bind:function (e,obj,vnode) {
        var w = $(e).attr("w");
        var h = $(e).attr("h");
        var init = $(e).attr("init-src");
        e.src = sy.getSrc(obj.value,w,h,init);
    },
    update:function (e,obj,vnode) {
        var w = $(e).attr("w");
        var h = $(e).attr("h");
        if (obj.value != obj.oldValue){
            e.src = sy.getSrc(obj.value,w,h);
        }
    }
});

Vue.filter('currency', function(value){
	if(!isNaN(value))return value.toFixed(2);
	return "";
});

Vue.directive('masonry', {
    bind: function (e,obj,vnode) {
        var directive = this;
        var element = this.el;
        var func = e.getAttribute('masonry-getData');
        var container = $(e);
        container.imagesLoaded(function(){
            container.masonry({
                columnWidth: 320,
                itemSelector : '.item',
                isFitWidth: true,//是否根据浏览器窗口大小自动适应默认false
                isAnimated: true,//是否采用jquery动画进行重拍版
                isRTL:false,//设置布局的排列方式，即：定位砖块时，是从左向右排列还是从右向左排列。默认值为false，即从左向右
                isResizable: true,//是否自动布局默认true
                animationOptions: {
                    duration: 800,
                    easing: 'easeInOutBack',//如果你引用了jQeasing这里就可以添加对应的动态动画效果，如果没引用删除这行，默认是匀速变化
                    queue: false//是否队列，从一点填充瀑布流
                }
            });
        });
        e.masonry = container;
    },
    update: function (value) {
        console.log(value)

    },
    unbind: function () {
        this.el.masonry = null;
    }
})